function gotoPay()
{
	var m=subCyar;//$("#money").val();
	
 var url= "pay.jsp?orderno=@no@&fee=@f@&name=@name@&callback_url=@url@";
 url=url.replace("@no@",orderno);
  url=url.replace("@f@",m*100);
   url=url.replace("@name@","game");
  // var urlxx="";
 
//000  alert(url);
     url=url.replace("@url@",  encodeURIComponent( pay_notify_url ));
 //  alert(url);
   window.location=url;
}


function btn_ev()
{
	  playAudio();
	 if($("#gameAccount").val()=="")
	 {
		 alert("用户id不能为空");
		 return;
	 }
	// var audio = $("#audio1")[0];  audio.currentTime=0;
	  
	//		audio.play(); 
			
			insertOrd( function(data){
				gotoPay();
			});
			
			  runExpEffect("#sumbitBtn");
	
}
 var orderno;

 function insertOrd(callx)
 {
	orderno=getUuid();
	//if(subCyar==0)
//	subCyar=	$("#money").val();
	 var dsl="com.attilax.ioc.IocFacV3_iocx_iocutil.getBean(com.attilax.order.RechargeOrderService.class).insert('@no@':s,@m@:i,@acc@:i)";
 dsl=dsl.replace("@no@",orderno).replace("@m@",subCyar).replace("@acc@",$("#gameAccount").val());
 // alert( subCyar);
  	var jsbrj=new	AtiJsBridge();
			var para={};
			para.dsl=dsl;
					 
			jsbrj.exe(para,function(data){
				console.log(data);
			    callx(data);
				
			}); 
	 
	 
	 
 }
 var subCyar=0;
 function  playAudio()
 {
	 
	  var aa = $("#audio1")[0];  
								   try{
								   aa.currentTime=0;
								   }catch(e){
									   console.log("---cur time not eff,load use");
									   aa.load();
									   }
									aa.play(); 
	 
 }

//schedule(this.update,2,16*1024,1);
   var PlayLayer={   //main layer,,one scence must hav a scence
	   curCyarIdx:-1,
	   cyararr:[5,20,50,100],
	   schedule:function(fun,interTime,repeat,delay){
		   window.setInterval(fun.bind(this),interTime*1000);
	   },
	    ctor:function () {
			
			 this.addSushi();
			 
			  this.schedule(this.addSushi,2,16*1024,1);
			
			},
			expFun: function(spr)
			{
				var tp=$(spr).offset().top; 
				var left=$(spr).offset().left;
					var imgStr='<img src="img/exp.gif" style="position:absolute; left:@lf@px; top:@t@px;width:100px;height:100px;"  class="sushi_tag_5kwi" />';
					imgStr=imgStr.replace("@lf@",left);
					imgStr=imgStr.replace("@t@",tp);
				 var $img=$(imgStr); 
				 $("body").append($img);
				 
				 //gc
							window.setTimeout(function(){
								 $img.remove();
								
							},700);
									
			},
	  addSushi : function() {
		  				//alert(this.curCyarIdx);
		  
		  				this.curCyarIdx++;
						if(this.curCyarIdx>3)
							this.curCyarIdx=0;
						
						var cyar=this.cyararr[this.curCyarIdx];
		  
						var docWid=$(document.body).width();	
											
						console.log("--docWid wid:"+docWid);
					
					
						 
						
						
						var imgStr='<img src="img/rmb@cyar@.jpg" style="position:absolute; left:0; top:0;"  class="cyar_tag" />';
					 //	imgStr=imgStr.replace("@w@",rdmWid);
						imgStr=imgStr.replace("@cyar@",cyar);
					//	 console.log("--imgStr:"+imgStr);
						var $h1=$(imgStr); 	
					$("body").append($h1);	
					 $h1.load(function(){  
								var w =  $h1.width();  
								var h = $h1.height();  
								
								var imgWid=$($h1).width();
							console.log("--imgWid wid:"+imgWid);
							var maxWid=docWid-imgWid;//maxWid=800;
							var rdmWid= Math.floor(Math.random()*(maxWid+1));
							console.log("--rdm wid:"+rdmWid);
							$h1.css("left",rdmWid+"px");
						}	);				
							
							
					
						//   this.addChild(sushi,5);
						// $(".sushi_tag_5kwi").css("top","0");
						//$(".sushi_tag_5kwi")
						
						
						//down move
						// var dorpAction = cc.MoveTo.create(4, cc.p(sushi.x,-30));
						//	sushi.runAction(dorpAction);
						$($h1).animate({top:"800px"},10000);
	 
	 					
						
						//gc
						 
							window.setTimeout(function(){
								 $($h1).remove();
								
							},6500);
							
							
							//add click
							$h1.on( "click", function() {
								 
									this.expFun($h1);//blood
								   //  playAudio();
								   subCyar=cyar;
								//   alert(subCyar);
								   
									 btn_ev();
									
									 }.bind(this) );
									 
								 
	 
			 }  //end add fun
	   
	   
	   };
//  PlayLayer.ctor();



//function 


var  	  addSushi =function() {

       // var sushi = new cc.Sprite(res.Sushi_png);
	    var docWid=$(document.body).width();
		
		
	var $h1=$('<img src="img/sushi.jpg" style="position:absolute; left:0; top:0;"  class="sushi_tag_5kwi" />');  
	$("body").append($h1);
    var imgWid=$($h1).width();
	var maxWid=docWid-imgWid;
	var minWid=0;
	var rdmWid= Math.floor(Math.random()*(maxWid-minWid+1)+maxWid);
     //   this.addChild(sushi,5);
	// $(".sushi_tag_5kwi").css("top","0");
	//$(".sushi_tag_5kwi")
		
		
		//down move
		// var dorpAction = cc.MoveTo.create(4, cc.p(sushi.x,-30));
	//	sushi.runAction(dorpAction);
	 $($h1).animate({top:"800px"},6000);
		
		//gc 
		window.setTimeout(function(){
			// cc.log("setTimeout is  sushi.removeFromParent !");
		//	sushi.removeFromParent();
			
		},5000);
    };
	
	
	//  3. schedule(callback, interval, repeat, delay, key)
	//   this.schedule(this.update,2,16*1024,1);